<template>
	<view class="page" :style="{'min-height':h+'px','padding-top':mt+'px'}">
		<c-nav-bar title="推荐菜品"></c-nav-bar>
		<view class="category-main">
			<block v-if="tuijianlist.length>0">
				<view v-for="(item,index) in tuijianlist" class="category-main-container" :key='index'>
					<view class="card-image">
						<image :src="item.coverImage"></image>
						<text style="margin: 30rpx 0;">{{item.name}}</text>
					</view>
				</view>
			</block>
			<block v-else>
				<view class="empty">空</view>
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				h: uni.getSystemInfoSync().windowHeight,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				tuijianlist: []
			}
		},
		onLoad(option) {
			this.getList(option.foodId)
		},
		methods: {
			getList(foodId) {
				this.$api.get(`/api/isFood/isfoodsuggest/${foodId}`).then(res => {
					if (res.data.code == 0) {
						this.tuijianlist = res.data.data;
					} else this.$showModal(res.data.msg);
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page {
		padding: 0 24rpx 40rpx;
		width: 100%;
		box-sizing: border-box;
		background: #fff;
	}

	.category-main {
		.empty{
			text-align: center;
			padding-top: 200rpx;
			font-size: 28rpx;
			color: #666666;
		}

		.category-main-container {
			float: left;
			width: calc(33.33% - 15rpx);
			margin-top: 24rpx;
			margin-left: 20rpx;
			&:nth-child(3n+1){
				margin-left: 0;
			}
		}

		.card-image {
			border-radius: 16rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 100%;
			height: 266rpx;
			background-color: #fff;
			// box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
			box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);

			image {
				width: 100%;
				height: 168rpx;
				border-radius: 16rpx;
			}
		}

		.category-main-container image {
			width: 100%;
			height: 168rpx;
		}

		.category-main-container text {
			margin-top: 5rpx;
			font-size: 26rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
		}
	}
</style>